package cc.rengu.igas.share.facade.bean.cups;

import cc.rengu.oltp.service.common.enums.OltpRpcdEnum;
import cc.rengu.oltp.service.model.BizException;

import java.util.Arrays;

/**
 * F60.3.9：卡账户等级<p>
 * 注：机构需根据报备卡样或申请卡 bin 时的发卡项目类型确定该取值
 *
 * @author fangminwei
 * @date 2021/4/17
 */
@SuppressWarnings("AlibabaEnumConstantsMustHaveComment")
public enum F60_3_9_AcctLevelEnum {
    _0("0", "未知"),
    _1("1", "普卡"),
    _2("2", "保留使用"),
    _3("3", "金卡"),
    _4("4", "白金卡"),
    _5("5", "钻石卡"),
    _6("6", "保留使用"),
    ;

    private String code;
    private String desc;

    F60_3_9_AcctLevelEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    @Override
    public String toString() {
        return code + "-" + desc;
    }

    public static F60_3_9_AcctLevelEnum find(String code) {
        F60_3_9_AcctLevelEnum result = Arrays.stream(F60_3_9_AcctLevelEnum.values())
                .filter(e -> e.getCode().equals(code)).findFirst().orElse(null);

        if (result == null) {
            throw new BizException(OltpRpcdEnum.PARAM_IS_EMPTY_OR_NULL.getRespCode(), "找不到对应的枚举信息" + code);
        }
        return result;
    }
}
